const path = require('path');
const fs = require('fs');

const getWatch = dir => dir.map(e => '../src/' + e + '/**/*');



module.exports = {
	base: {
		jsDir: '/js/app/',
		entry: path.join(__dirname, '../src/js/app'), //webpack入口
	},
	prod: {
		env: {
			NODE_ENV: '"production"'
		},
		publicPath: '/testProd/' //相对于根目录的发布URL,该URL可以不是该资源本体，比如是副本
	},
	dev: {
		env: {
			NODE_ENV: '"development"'
		}
	},
	watch:{
		other: '',
		//监听 js 的目录,相对于 src 目录
		js: getWatch([
			'js','components'
		])
	},
	server: {
		port: 8888,
		host: 'http://localhost',
		browser: 'chrome',
		fisServer: path.normalize("C:/Users/qkorb/AppData/Local/.fis3-tmp/www"),
		fegServer: path.normalize("C:/Users/qkorb/AppData/Local/.feg-tmp/www")
	},
	path: {
		src: path.join(__dirname, "../src"),
		middle: path.join(__dirname, "../build/middle"),
		local: path.join(__dirname, "../local"),
		dist: path.join(__dirname, "../dist"),
		tests: path.join(__dirname, "../tests")
	},
	polyfill:{
		//autoprefixer
		browsers: ["last 2 versions"]
	},
	fn: {
		getJS(dir) {
			let arr = fs.readdirSync(dir);
			return Object.assign(...arr.map(e => ({
				[e.replace('.js', '')]: path.join(dir, e)
			})));
		}
	}
}